package com.mmall.example.threadLocal;

import com.mmall.annoations.ThreadSafe;

/**
 * threadLocal ->线程封闭
 * Created by megan on 2018/3/31.
 */
@ThreadSafe
public class RequestHolder {

    private final static ThreadLocal<Long> requestHolder = new ThreadLocal<>();

    public static void add(Long id){
        requestHolder.set(id);
    }

    public static Long get(){
        return requestHolder.get();
    }

    public static void remove(){
        requestHolder.remove();
    }
}
